﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;

namespace EEPClientDBSocket
{
    public partial class frmMonitor : Form
    {
        public frmMonitor()
        {
            InitializeComponent();
        }

        private void frmMonitor_Load(object sender, EventArgs e)
        {
            XmlDocument DBXML = new XmlDocument();
            String s = Application.StartupPath + "\\EEPClientDBSocketMonitor.xml";
            ListViewItem aItem;
            ListViewItem.ListViewSubItem aSubItem;

            if (File.Exists(s))
            {
                try
                {
                    FileStream aFileStream = new FileStream(s, FileMode.Open, FileAccess.Read, FileShare.None);
                    DBXML.Load(aFileStream);
                    XmlNode aNode = DBXML.DocumentElement.FirstChild;
                    lvMonitor.BeginUpdate();
                    try
                    {
                        lvMonitor.Items.Clear();
                        while (aNode != null)
                        {
                            aItem = lvMonitor.Items.Add(aNode.Attributes["socketName"].InnerText);
                            aSubItem = aItem.SubItems.Add(new ListViewItem.ListViewSubItem(aItem, ""));
                            aSubItem.Text = aNode.Attributes["action"].InnerText;
                            aSubItem = aItem.SubItems.Add(new ListViewItem.ListViewSubItem(aItem, ""));
                            aSubItem.Text = aNode.Attributes["providerName"].InnerText;
                            aSubItem = aItem.SubItems.Add(new ListViewItem.ListViewSubItem(aItem, ""));
                            aSubItem.Text = aNode.Attributes["tableName"].InnerText;
                            aSubItem = aItem.SubItems.Add(new ListViewItem.ListViewSubItem(aItem, ""));
                            aSubItem.Text = aNode.Attributes["startTime"].InnerText;
                            aSubItem = aItem.SubItems.Add(new ListViewItem.ListViewSubItem(aItem, ""));
                            aSubItem.Text = aNode.Attributes["endTime"].InnerText;
                            aSubItem = aItem.SubItems.Add(new ListViewItem.ListViewSubItem(aItem, ""));
                            aNode = aNode.NextSibling;
                        }
                    }
                    finally
                    {
                        lvMonitor.EndUpdate();
                    }
                    aFileStream.Close();
                }
                catch
                { }
                finally
                {
                }
            }
        }
    }
}